package com.luojunchong.dubboconsumer;

import org.apache.dubbo.config.spring.context.annotation.EnableDubbo;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.system.ApplicationHome;

import java.io.File;

/**
 * @EnableDubbo：开启 Dubbo 自动配置（扫描 @DubboReference 注解）
 */

@EnableDubbo
@SpringBootApplication(scanBasePackages = "com.luojunchong.dubboconsumer")
public class DubboConsumerApplication {
    public static void main(String[] args) {
        //解决统一机器运行多个dubbo报错问题
        ApplicationHome home = new ApplicationHome(DubboConsumerApplication.class);
        File jarFile = home.getSource();
        String dirPath = jarFile.getParentFile().toString();
        String filePath = dirPath + File.separator + ".dubbo";
        System.out.println(filePath);
        System.setProperty("dubbo.meta.cache.filePath", filePath);
        System.setProperty("dubbo.mapping.cache.filePath",filePath);
        //启动
        SpringApplication.run(DubboConsumerApplication.class, args);
        System.out.println("=====================================");
        System.out.println(" Dubbo 消费者启动成功！端口：8081 ");
        System.out.println("=====================================");
    }
}
